<template>
  <div>
    <page-view>
      <template #form>
        <SearchForm :data-form="formInline" @on-search="onSearch" @onReset="onSearch">
          <el-form-item label="调度内容" prop="suffix" label-width="70px">
            <el-input v-model="formInline.suffix" placeholder="请输入调度内容" />
          </el-form-item>
        </SearchForm>
      </template>
      <template v-slot:table="tableScope">
        <PubilcTable :tableData="tableData" :tableHeight="tableScope.tableHeight" :list-config="columns"
          :page-data="pageData" @on-action="onAction" @on-switchChange="onSwitchChange"/>

      </template>
    </page-view>

  </div>
</template>
<script >
import api from '@/api/index'
export default {
  data () {
    return {
      formInline: {
        suffix: ''
      },
      pageData: {
        pageNum: 1,
        pageSize: 10,
        total: 0
      },
      tableData: [
        { code: '12345', suffix: '发票验真' },
        { code: '12345', suffix: '.jpeg' },
        { code: '12345', suffix: '.doc' },
        { code: '12345', suffix: '.xls' }

      ],

      columns: [
        { alias: 'suffix', label: '调度内容' },
        { alias: 'code', label: '启用状态', type: 'switch' }
      ]

    }
  },
  mounted () {
    // this.onSearch()

  },
  methods: {

    onSearch  () {
      const params = { ...this.formInline, ...this.pageData }
      api.dictsList(params).then((res) => {
        // this.tableData = res.list || []
        this.pageData.total = res.total || 0
      })
    },

    onAction ([item, row]) {
      const obj = {
        'pageNum': 'onSearch',
        'pageSize': 'onSearch'
      }
      this.pageData[item] = row
      if (item === 'pageSize') this.pageData.pageNum = 1
      this[obj[item]]()
    },
    onSwitchChange ([val, row, feild]) {
      console.log(val, row, feild)
    }

  }
}

</script>

<style lang="scss" scoped>
</style>
